package com.my.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.my.entity.Question;
import com.my.mapper.QuestionMapper;
import com.my.service.QuestionService;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> implements QuestionService {

    @Override
    public IPage<Question> getPage(IPage<Question> page, Question q) {
        page.setTotal(baseMapper.getCount(q));
        return page.setRecords(baseMapper.getPage((page.getCurrent() - 1) * page.getSize(), page.getSize(), q));
    }

    @Override
    public List<Question> getBySubjectId(Long subjectId) {
        return baseMapper.getBySubjectId(subjectId);
    }

}
